﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Management.master" AutoEventWireup="true"
    CodeFile="view-crm-brokers.aspx.cs" Inherits="admin_view_crm_brokers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <link href="includes/GridStyleSheet.css" rel="stylesheet" type="text/css" />
    <div class="contents">
        <table width="100%" cellpadding="3" cellspacing="0" border="0">
            <tr>
                <td>
                    <h1>
                        CRM Agents
                    </h1>
                </td>
            </tr>
            <tr id="trSearch" runat="server">
                <td>
                    <b>User</b> :
                    <asp:DropDownList ID="ddlUser" runat="server">
                        <asp:ListItem Value="0" Selected="True">All</asp:ListItem>
                        <asp:ListItem Value="100">Agent</asp:ListItem>
                        <asp:ListItem Value="200">Admin</asp:ListItem>
                        <asp:ListItem Value="300">Cashier</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp; <b>Campaign</b> :
                    <asp:DropDownList ID="ddlCampaign" runat="server">
                        <asp:ListItem Value="400">On-line</asp:ListItem>
                        <%--<asp:ListItem Value="1001">Off-line</asp:ListItem>--%>
                    </asp:DropDownList>
                    &nbsp;<b>Renewal Agent</b> :
                    <asp:DropDownList ID="ddlRenewal" runat="server">
                        <asp:ListItem Value="-1" Selected="True">All</asp:ListItem>
                        <asp:ListItem Value="0">New</asp:ListItem>
                        <asp:ListItem Value="1">Renew</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp; <b>Status</b> :
                    <asp:DropDownList ID="ddlStatus" runat="server">
                        <asp:ListItem Value="1" Selected="True">Active</asp:ListItem>
                        <asp:ListItem Value="0">Deactive</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />&nbsp;                        
                    &nbsp;<asp:Button ID="btnNewBroker" runat="server" OnClick="btnNewBroker_Click" Text="NewAgent" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblRecordCount" runat="server"></asp:Label>
                    <div style="display: none">
                        <asp:TextBox ID="txtReportType" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtReportDate1" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtReportDate2" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtReportDate" runat="server"></asp:TextBox>
                        <asp:TextBox runat="server" ReadOnly="true" ID="txtAgentId"></asp:TextBox>
                        <asp:Label ID="lblContent" runat="server"></asp:Label>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <%-- OnRowDataBound="grvBrokers_RowDataBound"--%>
                    <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
                    <div style="width: 100%; overflow: auto; height: auto;">
                        <div id="grdCharges" runat="server" style="width: 125%; height: auto;">
                            <asp:GridView ID="grvBrokers" runat="server" AutoGenerateColumns="False" DataKeyNames="RefCEUserId"
                                PageSize="8" CellSpacing="3" CellPadding="3" CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"
                                AllowPaging="true" EmptyDataText="There are no data records to display." GridLines="None"
                                Width="150%" OnPageIndexChanging="grvBrokers_PageIndexChanging" OnRowCommand="grvBrokers_RowCommand"
                                OnRowDataBound="grvBrokers_RowDataBound">
                                <Columns>
                                    <asp:BoundField DataField="RefCEUserId" HeaderText="Agent Id" SortExpression="RefCEUserId"
                                        ItemStyle-Width="100px" />
                                    <asp:BoundField DataField="BrokerCode" HeaderText="Agent" SortExpression="BrokerCode"
                                        ItemStyle-Width="100px" />
                                    <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" ItemStyle-Width="100px" />
                                    <asp:TemplateField HeaderText="Edit">
                                        <ItemTemplate>
                                            <asp:Button runat="server" ID="btnEdit" Text="Edit" CommandName="MyEdit" CommandArgument='<%#Eval("RefCEUserId")%>'
                                                OnClientClick="javascript:return SubmitEditConfirm();" CssClass="blueB ml10" />
                                            <div style="display: none;">
                                                <asp:Label ID="lblEditId" runat="server" Text='<%# Eval("RefCEUserId").ToString() %>'></asp:Label>
                                            </div>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Deactivate">
                                        <ItemTemplate>
                                            <asp:Button runat="server" ID="btnDeactivate" Text="Deactivate" CommandName="MyDeactivate"
                                                CommandArgument='<%#Eval("RefCEUserId")%>' OnClientClick="javascript:return SubmitDeactivateConfirm();"
                                                 ForeColor="Red" />
                                            <div style="display: none;">
                                                <asp:Label ID="lblDeactivateId" runat="server" Text='<%# Eval("RefCEUserId").ToString() %>'></asp:Label>
                                            </div>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="LeadAssign">
                                        <ItemTemplate>
                                            <asp:Button runat="server" ID="btnPause" Text="Pause" CommandName="MyPause"
                                                CommandArgument='<%#Eval("RefCEUserId")%>' OnClientClick="javascript:return SubmitLeadAssignPauseConfirm();"
                                                ForeColor="Blue" Width="70px" />
                                            <asp:Button runat="server" ID="btnResume" Text="Resume" CommandName="MyResume"
                                                CommandArgument='<%#Eval("RefCEUserId")%>' OnClientClick="javascript:return SubmitLeadAssignResumeConfirm();"
                                                ForeColor="Green" Width="70px" />
                                            <div style="display: none;">
                                                <asp:Label ID="lblLeadAssignUserId" runat="server" Text='<%# Eval("RefCEUserId").ToString() %>'></asp:Label>
                                            </div>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" ItemStyle-Width="450px" />
                                    <asp:BoundField DataField="THName" HeaderText="THName" SortExpression="THName" ItemStyle-Width="320px" />
                                    <asp:BoundField DataField="ENName" HeaderText="ENName" SortExpression="ENName" ItemStyle-Width="320px" />
                                    <asp:BoundField DataField="NickName" HeaderText="NickName" SortExpression="NickName"
                                        ItemStyle-Width="175px" />
                                    <asp:BoundField DataField="UserRole" HeaderText="Role" SortExpression="UserRole"
                                        ItemStyle-Width="100px" />
                                    <asp:BoundField DataField="Level" HeaderText="Level" SortExpression="Level" ItemStyle-Width="280px" />
                                    <asp:BoundField DataField="Renewal" HeaderText="Renewal" SortExpression="Renewal"
                                        ItemStyle-Width="100px" />
                                    <asp:BoundField DataField="Campaign" HeaderText="Campaign" SortExpression="Campaign"
                                        ItemStyle-Width="100px" />
                                    <asp:BoundField DataField="THPhone" HeaderText="THPhone" SortExpression="THPhone"
                                        ItemStyle-Width="290px" />
                                    <asp:BoundField DataField="ENPhone" HeaderText="ENPhone" SortExpression="ENPhone"
                                        ItemStyle-Width="290px" />
                                    <asp:BoundField DataField="DID" HeaderText="DID" SortExpression="DID" ItemStyle-Width="200px" />
                                    <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" ItemStyle-Width="100px" />
                                    <asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" ItemStyle-Width="150px" />
                                    <asp:BoundField DataField="License" HeaderText="License" SortExpression="License"
                                        ItemStyle-Width="150px" />
                                    <asp:BoundField DataField="EffectiveFrom" HeaderText="EffectiveFrom" SortExpression="EffectiveFrom"
                                        ItemStyle-Width="200px" />
                                    <asp:BoundField DataField="EffectiveTo" HeaderText="Effective Until" SortExpression="EffectiveTo"
                                        ItemStyle-Width="200px" Visible="false" />
                                </Columns>
                                <FooterStyle />
                                <PagerStyle />
                                <SelectedRowStyle />
                                <HeaderStyle CssClass="admin_gridheader" />
                                <EditRowStyle />
                                <AlternatingRowStyle CssClass="admin_gridodd" />
                                <RowStyle CssClass="admin_grideven" />
                            </asp:GridView>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div>

    <script type="text/javascript">
        function SubmitDeactivateConfirm() {
            var _retVal = false;
            _retVal = confirm('Are you Sure to DECATIVATE this Broker Account?');
            return _retVal;
        }

        function SubmitEditConfirm() {
            var _retVal = false;
            _retVal = confirm('Are you Sure to GO EDIT this Broker Account?');
            return _retVal;
        }
        
        function SubmitLeadAssignPauseConfirm() {
            var _retVal = false;
            _retVal = confirm('Are you Sure to PAUSE Auto Lead Assignment to this Broker?');
            return _retVal;
        }

        function SubmitLeadAssignResumeConfirm() {
            var _retVal = false;
            _retVal = confirm('Are you Sure to RESUME Auto Lead Assignment to this Broker?');
            return _retVal;
        }

    </script>

</asp:Content>
